﻿using GameControler.Emgu;
using PlatformCommon.Manager;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GameControler.Game
{
    public class MoveView : ViewObject
    {
        public override string FloderName
        {
            get { return "MoveView"; }
        }

        private static MoveView instance;
        public static MoveView Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = new MoveView();
                }
                return instance;
            }
        }

        protected MoveView()
            : base()
        {

        }

        public override bool IsCurrentView(System.Drawing.Bitmap intputbmp)
        {
            var ismove = base.IsCurrentView(intputbmp);
            if (IsInitTemplate && Templates.Count > 0 && !ismove)
            {
                foreach (var item in this.Templates)
                {
                    var mdhsv = JilyEmgu.MatchAllResultHSV(intputbmp, item);
                    if (mdhsv.IsMatch)
                    {
                        Log4Wrap.Logger.Info("Move界面匹配" + "__mdhsv_" + mdhsv.TemplateView.Name + "___" + "战斗界面右移");
                        return true;
                    }
                    var mdgray = JilyEmgu.MatchAllResultGray(intputbmp, item);
                    if (mdgray.IsMatch)
                    {
                        Log4Wrap.Logger.Info("Move界面匹配" + "__mdgray_" + mdgray.TemplateView.Name + "___" + "战斗界面右移");
                        return true;
                    }
                    var mdrgb = JilyEmgu.MatchAllResultRGB(intputbmp, item);
                    if (mdrgb.IsMatch)
                    {
                        Log4Wrap.Logger.Info("Move界面匹配" + "__mdrgb_" + mdrgb.TemplateView.Name + "___" + "战斗界面右移");
                        return true;
                    }

                    var md = JilyEmgu.MatchResult(intputbmp, item);
                    if (md.IsMatch)
                    {
                        Log4Wrap.Logger.Info("Move界面匹配" + "__MatchResult_" + mdhsv.TemplateView.Name + "___" + "战斗界面右移");
                        return true;
                    }
                }
            }
            if (ismove)
            {
                Log4Wrap.Logger.Info("GoOn界面匹配" + "__ViewObject_" + "___" + "战斗界面右移");
            }
            return ismove;
        }

    }
}
